import requests
import json
def get_access_token():
    """
    使用 API Key，Secret Key 获取access_token，替换下列示例中的应用API Key、应用Secret Key
    """

    url = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=8uPCcFsqhbvW6yzueLI3Q7zb&client_secret=p0LThuVqUpa2C0LOEvFMNr5rxDA3hZRR"

    payload = json.dumps("")
    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }

    response = requests.request("POST", url, headers=headers, data=payload)
    return response.json().get("access_token")
def main(discipline,rules,standard,student):
    url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/plugin/wti0zce20ak7vtq5/?access_token=" + get_access_token()
    discipline = discipline
    rules = rules
    standard = standard
    student = student
    payload = json.dumps({
        "query": "",
        "input_variables":{"discipline":discipline,"rules":rules,"standard": standard,"student":student},
        "verbose": True
    })
    headers = {
        'Content-Type': 'application/json'
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    la = response.json().get('result')
    return la
    # clean_json_string = la.strip('```')
    # result_dict = json.loads(clean_json_string)
    # print(result_dict)